package com.qianyu.api.controller.comm;

import com.qianyu.core.entity.base.Result;
import com.qianyu.core.entity.dto.api.OpenNotifyDto;
import com.qianyu.core.entity.vo.AppidAndQqVo;
import com.qianyu.core.service.QqAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Api(tags = "上号器", description = "wangzhicheng")
@RestController
@RequestMapping("/api/open")
@RequiredArgsConstructor
public class ApiCommonController {

    private final QqAccountService qqAccountService;

    /**
     * 通过qq登录值获取登录open
     */
    @GetMapping("/getQqOpen")
    @ApiOperation(value = "通过qq登录值获取登录open")
    Result<String> getQqOpen(@RequestParam String appid, @RequestParam String loginVal) {
        return Result.success(qqAccountService.getQqOpen(appid, loginVal));
    }

    /**
     * 刷open取号
     */
    @GetMapping("/getOpen")
    @ApiOperation(value = "刷open取号")
    Result<AppidAndQqVo> getOpen() {
        return Result.success(qqAccountService.getOpen());
    }

    /**
     * 刷open回调
     */
    @PostMapping("/openNotify")
    @ApiOperation(value = "刷open回调")
    Result<String> openNotify(@RequestBody OpenNotifyDto dto){
        qqAccountService.openNotify(dto);
        return Result.success();
    }
}
